package com.zhangjinghao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhangjinghao.entity.Food;
import com.zhangjinghao.entity.SelectArg;
import com.zhangjinghao.es.FoodRepository;
import com.zhangjinghao.mapper.FoodMapper;
import com.zhangjinghao.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FoodServiceImpl implements FoodService {

    @Autowired
    private FoodMapper foodMapper;

    @Override
    public List<Food> selectList(SelectArg selectArg) {
        return foodMapper.selectList(selectArg);
    }

    @Override
    public PageInfo<Food> pageInfo(SelectArg selectArg) {
        PageHelper.startPage(selectArg.getPageNum(),selectArg.getPageSize());
        return new PageInfo<>(foodMapper.selectList(selectArg));
    }

    @Override
    public int insert(Food food) {

        return foodMapper.insert(food);
    }

    @Override
    public int update(Food food) {

        return foodMapper.update(food);
    }

    @Override
    public int delete(String ids) {
        return foodMapper.delete(ids);
    }

    @Override
    public Food selectById(Integer id) {
        return foodMapper.selectById(id);
    }
}
